package cn.micro.system.manage.service.impl;

import cn.micro.system.manage.entity.SysDimProfession;
import cn.micro.system.manage.entity.dto.SysDimProfessionSearch;
import cn.micro.system.manage.mapper.SysDimProfessionMapper;
import cn.micro.system.manage.service.SysDimProfessionService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Consumer;

/**
 * <p>
 * 职务表 服务实现类
 * </p>
 *
 * @author wr
 * @since 2023-12-29
 */
@Service
public class SysDimProfessionServiceImpl extends ServiceImpl<SysDimProfessionMapper, SysDimProfession> implements SysDimProfessionService {

    @Override
    public List<SysDimProfession> getByCodeOrName(SysDimProfession sysDimProfession) {
        LambdaQueryWrapper<SysDimProfession> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.and(sysDimProfessionLambdaQueryWrapper -> sysDimProfessionLambdaQueryWrapper.eq(StringUtils.isNotEmpty(sysDimProfession.getCode()), SysDimProfession::getCode, sysDimProfession.getCode())
                .eq(StringUtils.isNotEmpty(sysDimProfession.getName()), SysDimProfession::getName, sysDimProfession.getName())).ne(StringUtils.isNotBlank(sysDimProfession.getId()), SysDimProfession::getId, sysDimProfession.getId());
        return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<SysDimProfession> listByPage(int page, int size, SysDimProfessionSearch search) {
        PageHelper.startPage(page,size);
        return this.baseMapper.queryByPage(search);
    }


}
